<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Adds javascript code to the FDF document</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.fdf-add-doc-javascript" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">fdf_add_doc_javascript</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">fdf_add_doc_javascript</span> &mdash; <span class="dc-title">Adds javascript code to the FDF document</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.fdf-add-doc-javascript-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>fdf_add_doc_javascript</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$fdf_document</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$script_name</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$script_code</code></span>
   ) : <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Adds a script to the FDF, which Acrobat then adds to the doc-level scripts
   of a document, once the FDF is imported into it. 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.fdf-add-doc-javascript-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">fdf_document</code></dt>

     <dd>

      <p class="para">
       The FDF document handle, returned by <span class="function"><a href="fdf_create.html" class="function">fdf_create()</a></span>,
       <span class="function"><a href="fdf_open.html" class="function">fdf_open()</a></span> or <span class="function"><a href="fdf_open_string.html" class="function">fdf_open_string()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">script_name</code></dt>

     <dd>

      <p class="para">
       The script name.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">script_code</code></dt>

     <dd>

      <p class="para">
       The script code. It is strongly suggested to use <em>\r</em>
       for linebreaks within the script code.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.fdf-add-doc-javascript-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.fdf-add-doc-javascript-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4149">
    <p><strong>Example #1 Adding JavaScript code to a FDF</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fdf&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fdf_create</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">fdf_add_doc_javascript</span><span style="color: #007700">(</span><span style="color: #0000BB">$fdf</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"PlusOne"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"function&nbsp;PlusOne(x)\r{\r&nbsp;&nbsp;return&nbsp;x+1;\r}\r"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fdf_save</span><span style="color: #007700">(</span><span style="color: #0000BB">$fdf</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>
     will create a FDF like this:
    </p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
%FDF-1.2
%âãÏÓ
1 0 obj
&lt;&lt;
/FDF &lt;&lt; /JavaScript &lt;&lt; /Doc [ (PlusOne)(function PlusOne\(x\)\r{\r  return x+1;\r}\r)] &gt;&gt; &gt;&gt;
&gt;&gt;
endobj
trailer
&lt;&lt;
/Root 1 0 R

&gt;&gt;
%%EOF
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div></div></div></body></html>